import Express from "express"
import "reflect-metadata"
import config from "../config"
import Routers from "./router"
import { resHandler, errHandler } from "./public/classes/middleWare"
// 创建express应用
const app = Express()

// express中间件
app.use(Express.raw(), Express.json())

// 响应中间件
app.use(resHandler)
// 路由
app.use('/api', Routers)
// 全局错误捕获
app.use(errHandler)

// 监听端口运行
app.listen(config.port, () => {
  console.log(`app is running at http://localhost:${config.port}`);
})